$(() => {obj.init();});

let obj = {
    dataGrid: null,
    dom: {
        btn: {
            del: null
        }
    },
    init: function () {
        this.dom.btn.del = $('#bt_list_del');

        this.dataGrid = new xhDataGrid($('#list'), 'remind/getTask');
        this.dataGrid.parseToolbar().init().activeBtn(this.dom.btn.del);

        this.listener();
    },
    listener: function () {
        //双击打开消息
        this.dataGrid.onDblClickRow = (rowIndex, rowData) => {
            this.funObj().viewTask(rowIndex, rowData);
        };
        //删除
        this.dom.btn.del.click(() => {
            if (xhExtra.buttonDisabled(this.dom.btn.del)) {
                return false;
            }
            this.funObj().delNotice();
        });
    },
    funObj: function () {
        return {
            viewTask: (rowIndex, rowData) => {
                //联动首页消息
                window.top.msg.funObj().viewTask(rowData.taskId);
            },
            delNotice: () => {
                xhExtra.askChangeStatus(
                    'remind/delTask',
                    {ids: this.dataGrid.getSelectValues('id')},
                    this.dataGrid,
                    '确认删除？',
                    (result) => {
                        //联动首页初始化
                        window.top.msg.funObj().initMsg();
                    }
                );
            }
        }
    }
};